package com.lh.marketing;

import cn.hutool.json.JSON;
import cn.hutool.json.JSONUtil;
import com.lh.marketing.canvas.rules.ConditionEntity;
import com.lh.marketing.canvas.rules.ConditionParser;

public class Rule {
    public static void main(String[] args) {
        System.out.println(JSONUtil.parseObj(str));
        System.out.println(JSONUtil.toBean(JSONUtil.parseObj(str), ConditionEntity.class));
        System.out.println(ConditionParser.parseToExpression(JSONUtil.toBean(JSONUtil.parseObj(str), ConditionEntity.class)));
    }
    static String str = "{\n" +
            "    \"val\":\"\",\n" +
            "    \"expression\":\"\",\n" +
            "    \"joinOperator\":\"And\",\n" +
            "    \"operator\":\"\",\n" +
            "    \"children\":[\n" +
            "        {\n" +
            "            \"val\":\"Lily\",\n" +
            "            \"expression\":\"name == 'Lily'\",\n" +
            "            \"joinOperator\":\"Or\",\n" +
            "            \"operator\":\"==\",\n" +
            "            \"children\":null,\n" +
            "            \"propertyType\":\"string\",\n" +
            "            \"showType\":\"Expression\",\n" +
            "            \"key\":\"name\"\n" +
            "        },\n" +
            "        {\n" +
            "            \"val\":18,\n" +
            "            \"expression\":\"age == 18\",\n" +
            "            \"joinOperator\":\"Or\",\n" +
            "            \"operator\":\"==\",\n" +
            "            \"children\":null,\n" +
            "            \"propertyType\":\"number\",\n" +
            "            \"showType\":\"Expression\",\n" +
            "            \"key\":\"age\"\n" +
            "        }\n" +
            "    ],\n" +
            "    \"propertyType\":\"\",\n" +
            "    \"showType\":\"\",\n" +
            "    \"key\":\"\"\n" +
            "}";

}
